from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from users import views

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UserNameView.as_view()),
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileNumbersView.as_view()),
    url(r'^users/$', views.UserView.as_view()),
    url(r'^email/$', views.EmailView.as_view()),
    url(r'^emails/verification/$', views.EmailVerifyView.as_view()),
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^user/$', views.UserDetailView.as_view()),
    url(r'^browse_histories/$', views.BrowseHistoriesView.as_view()),
    url(r'^image_codes/(?P<pk>.+)/$', views.GenerateImageCodeView.as_view()),
    url(r'^accounts/(?P<pk>.+)/sms/token/$', views.FindMobileView.as_view()),
    url(r'sms_codes/$', views.SMSCodeView.as_view()),
    url(r'^accounts/(?P<username>.+)/password/token/$', views.VerifySmscodeView.as_view()),
    url(r'^users/(?P<pk>\d+)/password/$', views.SavePasswordView.as_view()),
    # url(r'^user/(?P<user_id>\d+)/password/$', views.UpdatePasswordView.as_view()),
]

# 路由router
from rest_framework.routers import DefaultRouter

router = DefaultRouter()

router.register('addresses', views.AddressViewSet, base_name='addresses')
urlpatterns += router.urls